﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace LowLevelGraphics.ImageFormats.SVG.Shapes
{
    /// <summary>
    /// 
    /// </summary>
    public class Circle : Shape
    {
        protected float m_fRadius = -1.0f;

        /// <summary>
        /// Initializes a new instance of the <see cref="Circle"/> class.
        /// </summary>
        public Circle()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Circle"/> class.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="r">The r.</param>
        public Circle(float x, float y, float r)
        {
            this.Location = new PointF(x, y);
            this.m_fRadius = r;
        }

        /// <summary>
        /// Gets or sets the radius.
        /// </summary>
        /// <value>The radius.</value>
        public float Radius
        {
            get { return m_fRadius; }
            set { m_fRadius = value; }
        }

        /// <summary>
        /// Draws the specified g.
        /// </summary>
        /// <param name="g">The g.</param>
        public override void Draw(Graphics g)
        {
            Brush brushFill = new SolidBrush(m_Style.FillColor);

            Brush brushStroke = new SolidBrush(m_Style.StrokeColor);
            Pen pen = new Pen(brushStroke, m_Style.StrokeWidth / 2.0f);
            if (m_Style.FillColor != Color.Transparent)
            {
                g.FillEllipse(brushFill, this.X - m_fRadius / 2, this.Y - m_fRadius / 2, this.m_fRadius, this.m_fRadius);
                g.DrawEllipse(pen, this.X - m_fRadius / 2, this.Y - m_fRadius / 2, this.m_fRadius, this.m_fRadius);
            }
            else
            {
                g.DrawEllipse(pen, this.X - m_fRadius / 2, this.Y - m_fRadius / 2, this.m_fRadius, this.m_fRadius);
            }
            pen.Dispose();
            brushStroke.Dispose();
            brushFill.Dispose();
        }
    }
}
